I tried to manipulate with the option "beforedatavalidated" this json data:
[("air":{
"indicateur": 4
},
"date": "2021-09-10"
},{
"air":{
"indicateur": 3
},
"date": "2021-09-11"
},{
"air":{
"indicateur": 1
},
"date": "2021-09-12"
},{
"air":{
"indicateur": 1
},
"date": "2021-09-08"
}]
Here is a part of the configuration of the charts:
// Create axes
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "date";
categoryAxis.renderer.grid.template.location = 0;
categoryAxis.renderer.minGridDistance = 150;
categoryAxis.tooltip.disabled = "visible";
categoryAxis.renderer.labels.template.adapter.add("dy", function(dy, target) {
if (target.dataItem && target.dataItem.index & 2 == 2) {
return dy + 0;
}
return dy;
})
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.renderer.minWidth = 50;
valueAxis.min = 0;
valueAxis.cursorTooltipEnabled = false;
// Create series
var series = chart.series.push(new am4charts.ColumnSeries());
series.sequencedInterpolation = "visible";
//series.data.value = air;
series.dataFields.valueY = "air";
series.dataFields.categoryX = "date";
series.tooltipText = "[{categoryX}: bold]{valueY}[/]";
series.columns.template.strokeWidth = 0;
series.columns.template.column.cornerRadiusTopLeft = 10;
series.columns.template.column.cornerRadiusTopRight = 10;
//series.fill = am4core.color("#50f0e6");
series.data.events.on("beforedatavalidated", function(ev){
var source = ev.target.chart.data;
if (source.air) {
ev.target.chart.data = source.air.indicateur;
}
});
I tried to access "indicateur" value but fail at all. I tried to look all over amcharts documentation and could not still understand how to do it in this situation.
Big thanks in advance